package com.xykj.mythy.rest;

import com.xykj.mythy.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/web/api/user")
public class UserController {

    @RequestMapping("/")
    public String init(Model model){
        List<User> users = new ArrayList<>();
        for (int i=0;i<10;i++) {
            users.add(new User(i,i+"余三女",18,"<<云铜科技园>>"));
        }
        model.addAttribute("users",users);
        return "user/list";
    }


    @ResponseBody
    @RequestMapping("/list")
    public List<User> list(Model model){
        List<User> users = new ArrayList<>();
        User user = new User(1,"emery",22,"云南省保山市隆阳区板桥镇沙灯村");
        users.add(user);
        User user1 = new User(2,"netty",32,"云南省昆明市五华区黄土坡车场");
        users.add(user1);
        User user2 = new User(3,"luxy",19,"云南省楚雄州南华县菌子交易市场");
        users.add(user2);
        return users;
    }


    @RequestMapping("/main")
    public String main(){

        return "user/main";
    }


    @RequestMapping("/login")
    public String login(){

        return "user/login";
    }


    @RequestMapping("/monitor")
    public String monitor(){

        return "user/monitor";
    }

}
